package com.web.music.model;

import java.util.List;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.OneToOne;

@Entity
@DiscriminatorValue("SINGER")
public class Singer extends Artist {

	private String name;
	
	private String singerAttribute;
	
	@OneToOne
	private Person person = null;
	
	public Singer() {
		super();
	}

	public Singer(Long Id, String name, String singerAttribute) {
		super(Id);
		this.name = name;
		this.singerAttribute = singerAttribute;
	}
	
	public Singer(Long id, String name, String singerAttribute, Person person, List<Genre> genres) {
		super(genres, id);
		this.name = name;
		this.person = person;
		this.singerAttribute = singerAttribute;
	}
	
	public String getName(){
		return name;
	}
	
	public String getSingerAttribute(){
		return singerAttribute;
	}

	public void setSingerAttribute(String singerAttribute ){
		this.singerAttribute = singerAttribute;
	}

	public void setName(String name ){
		this.name = name;
	}

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}
	
	@Override
	public boolean equals(Object obj) {
		boolean result = true;
		if (obj instanceof Singer) {
			result = this.name.equals(((Singer) obj).getName())
						&& this.singerAttribute.equals(((Singer) obj).getSingerAttribute())
						&& this.getId().equals(((Singer) obj).getId())
						&& this.person.equals(((Singer) obj).getPerson());
			return result;
		}
		return false;
	}

	@Override
	public String toString() {
		return this.name + " " + this.singerAttribute + " " + getId();
	}
	
	@Override
	public int hashCode() {
		return toString().hashCode();
	}


}
